package com.rocpenghua.config;
import com.intellij.openapi.application.ApplicationManager;
import com.intellij.openapi.components.PersistentStateComponent;
import com.intellij.openapi.components.State;
import com.intellij.openapi.components.Storage;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;

@State(
        name = "com.rocpenghua.config.PluginSettings",
        storages = {@Storage("AICodeAssistantSettings.xml")}
)
public class PluginSettings implements PersistentStateComponent<PluginSettings.State> {
    public static class State {
        public String apiKey = "";
        public String baseUrl = "https://api.deepseek.com/chat";
        public String selectedModel = "deepseek-chat";
    }

    private State myState = new State();

    public static PluginSettings getInstance() {
        return ApplicationManager.getApplication().getService(PluginSettings.class);
    }

    @Nullable
    @Override
    public State getState() {
        return myState;
    }

    @Override
    public void loadState(@NotNull State state) {
        myState = state;
    }

    public String getApiKey() {
        return myState.apiKey;
    }

    public void setApiKey(String apiKey) {
        myState.apiKey = apiKey;
    }

    public String getBaseUrl() {
        return myState.baseUrl;
    }

    public void setBaseUrl(String baseUrl) {
        myState.baseUrl = baseUrl;
    }

    public String getSelectedModel() {
        return myState.selectedModel;
    }

    public void setSelectedModel(String selectedModel) {
        myState.selectedModel = selectedModel;
    }
}
